#ifndef MEMFILE_H
#define MEMFILE_H
/*//////////////////////////////////////////////////////////////////////////
/* Memory based file implementation */

typedef unsigned char BYTE;
typedef unsigned int UINT;
typedef unsigned long DWORD;
typedef int BOOL;
typedef long LONG;

typedef struct tagMemFile
{
	UINT m_nGrowBytes;
	DWORD m_nPosition;
	DWORD m_nBufferSize;
	DWORD m_nFileSize;
	BYTE* m_lpBuffer;
	BOOL m_bAutoDelete;
	BOOL m_bWriteError;
} MemFile;

MemFile *mfopen(BYTE* lpBuffer, UINT nBufferSize, UINT nGrowBytes /* = 0*/);
MemFile *mfopen_w(UINT nGrowBytes /* = 1024 */);
int mfclose(MemFile *f);
DWORD mftell(MemFile *f);
LONG mfseek(MemFile *f, LONG lOff, UINT nFrom);
void mfrewind(MemFile *f);
UINT mfread(void* lpBuf, UINT nCount, MemFile *f);
UINT mfwrite(const void* lpBuf, UINT nCount, MemFile *f);
int mfgetc(MemFile *f);
int mfputc(int c, MemFile *f);
int mfungetc(int c, MemFile *f);
BOOL mfwrite_error(MemFile *f);
DWORD mfsize(MemFile *f);
int mfputs(const char *s, MemFile *f);
#define mferror(f) mfwrite_error(f)
#define mfflush(f)
#endif

